<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<html>
<head>
    <title>乐购商品管理</title>
    <meta name="decorator" content="default"/>
    <script type="text/javascript">
        $(document).ready(function () {

        });

        function page(n, s) {
            $("#pageNo").val(n);
            $("#pageSize").val(s);
            $("#searchForm").submit();
            return false;
        }

        function getIds() {
            var ids = [];
            $("input[name='ids']:checked").each(function () {
                ids.push({id: $(this).val(), name: $(this).attr("label")});
            });
            return ids;
        }
    </script>
</head>
<body>
<ul class="nav nav-tabs">
    <li class="active"><a href="${ctx}/shop/product/hkShopProduct/">乐购商品列表</a></li>
    <c:if test="${ empty hkShopProduct.checked}">
        <shiro:hasPermission name="shop:product:hkShopProduct:edit">
            <li>
                <a href="${ctx}/shop/product/hkShopProduct/form">乐购商品添加</a></li>
        </shiro:hasPermission>
    </c:if>
</ul>
<form:form id="searchForm" modelAttribute="hkShopProduct" action="${ctx}/shop/product/hkShopProduct/" method="post"
           class="breadcrumb form-search">
    <input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
    <input id="checked" name="checked" type="hidden" value="${hkShopProduct.checked}"/>
    <input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
    <ul class="ul-form">
        <li><label>名称：</label>
            <form:input path="title" htmlEscape="false" maxlength="200" class="input-small"/>
        </li>
        <li><label>分类：</label><sys:treeselect id="categoryId" name="category.id" labelName="category.name"
                                              labelValue="${hkShopProduct.category.name}"
                                              value="${hkShopProduct.category.id}"
                                              title="分类" url="/shop/category/hkShopCategory/treeData"
                                              cssClass="input-small"
                                              allowClear="true"/>
        </li>
        <li><label>状态：</label>
            <form:select path="state" class="input-small">
                <form:option value="" label="全部"/>
                <form:options items="${fns:getDictList('hk_shop_state')}" itemLabel="label" itemValue="value"
                              htmlEscape="false"/>
            </form:select>
        </li>
        <li><label>是否新品：</label>
            <form:select path="isnew" class="input-small">
                <form:option value="" label="全部"/>
                <form:options items="${fns:getDictList('yes_no')}" itemLabel="label" itemValue="value"
                              htmlEscape="false"/>
            </form:select>
        </li>

        <li><label>品牌：</label>
            <form:select path="brand.id" class="input-medium">
                <form:option value="" label=""/>
                <form:options items="${brands}" itemLabel="name" itemValue="id" htmlEscape="false"/>
            </form:select>
        </li>

        <li class="btns"><input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/></li>
        <li class="clearfix"></li>
    </ul>
</form:form>
<sys:message content="${message}"/>
<table id="contentTable" class="table   table-bordered table-condensed table-hover">
    <thead>
    <tr>
        <c:if test="${not empty hkShopProduct.checked}">
            <th>选择</th>
        </c:if>
        <th>商品名称</th>
        <th>店铺名称</th>
        <th>店铺账号</th>
        <th>状态</th>
        <th>商品主图</th>
        <th>乐币</th>
        <th>分类</th>
        <th>是否新品</th>
        <th>更新时间</th>
        <th>备注</th>
        <c:if test="${ empty hkShopProduct.checked}">
            <shiro:hasPermission name="shop:product:hkShopProduct:edit">
                <th>操作</th>
            </shiro:hasPermission>
        </c:if>
    </tr>
    </thead>
    <tbody>
    <c:forEach items="${page.list}" var="hkShopProduct2">
        <tr>
            <c:if test="${not empty hkShopProduct.checked}">
                <td>
                    <input type="checkbox" name="ids" value="${hkShopProduct2.id}" label="${hkShopProduct2.title}">
                </td>
            </c:if>
            <td>
                <c:if test="${not empty hkShopProduct.checked}">
                    ${hkShopProduct2.title}
                </c:if>
                <c:if test="${ empty hkShopProduct.checked}">
                    <a href="${ctx}/shop/product/hkShopProduct/form?id=${hkShopProduct2.id}">
                            ${hkShopProduct2.title}
                    </a>
                </c:if>
            </td>
            <td>
                    ${hkShopProduct2.shop.name}
            </td>
            <td>
                    ${hkShopProduct2.user.loginName}
            </td>
            <td>
                    ${fns:getDictLabel(hkShopProduct2.state, 'hk_shop_state', '')}
            </td>
            <td><img src="${hkShopProduct2.imgSrc}" class="img-rounded" width="60px" height="60px"/>
            </td>
            <td>
                    ${hkShopProduct2.integral}
            </td>
            <td>
                    ${hkShopProduct2.category.name}
            </td>
            <td>
                    ${fns:getDictLabel(hkShopProduct2.isnew, 'yes_no', '')}
            </td>
            <td>
                <fmt:formatDate value="${hkShopProduct2.updateDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
            </td>
            <td>
                    ${hkShopProduct2.remarks}
            </td>
            <c:if test="${ empty hkShopProduct.checked}">
                <shiro:hasPermission name="shop:product:hkShopProduct:edit">
                    <td>
                        <a href="${ctx}/shop/product/hkShopProduct/form?id=${hkShopProduct2.id}">修改</a>
                            <%--<a href="${ctx}/shop/product/hkShopProductSku/list?product.id=${hkShopProduct2.id}">sku管理</a>
                            <a href="${ctx}/shop/product/hkShopProductColor/list?product.id=${hkShopProduct2.id}">sku图片</a>--%>
                        <a href="${ctx}/shop/product/hkShopProduct/delete?id=${hkShopProduct2.id}"
                           onclick="return confirmx('确认要删除该乐购商品吗？', this.href)">删除</a>
                    </td>
                </shiro:hasPermission>
            </c:if>
        </tr>
    </c:forEach>
    </tbody>
</table>
<div class="pagination">${page}</div>
</body>
</html>